'''
    @author : walker
    @time : 2019/10/9
    @description : 对泰坦尼克训练集进行画图操作
'''

import seaborn as sns
import matplotlib.pyplot as plt

#设置画图的字体
plt.style.use("fivethirtyeight")
sns.set_style({'font.sans-serif':['simhei','Arial']})

class analysis_titanic_train_data(object):
    def __init__(self,train_data):
        self.train_data = train_data

    def age_analysis(self):
        '''
            对age进行特征分析
            param:
                self.train_data
            return:
                age_pic : 年龄的图
        '''
        f,ax1 = plt.subplots(figsize = (20,7))
        sns.countplot(y = 'Age',data = self.train_data,ax = ax1)
        ax1.set_title('年龄分布',fontsize=15)
        ax1.set_xlabel('数量')
        ax1.set_ylabel('年龄')
        plt.show()

        # f,ax1 = plt.subplots(figsize = (20,7))
        # sns.countplot(y = 'Age_param',data = self.train_data,ax = ax1)
        # ax1.set_title('年龄分布',fontsize=15)
        # ax1.set_xlabel('数量')
        # ax1.set_ylabel('年龄阶段')
        # plt.show()

    def embarked_analysis(self):
        '''
            对上船地点进行特征分析
            得到的是在S点上船的人最多
            param:
                self.train_data
            return:
                embarked_pic
        '''
        f,ax1 = plt.subplots(figsize = (10,7))
        sns.countplot(self.train_data['Embarked'],ax = ax1)
        ax1.set_title("上船地址分析")
        ax1.set_xlabel('地址')
        ax1.set_ylabel("数量")
        plt.show()
